<template>
	<div>
		
    <!-- 更新措施弹窗 -->
    <el-dialog 
      title="风险点管控"
      append-to-body
      :visible.sync="riskControlDialog"
      :close-on-click-modal="false" 
      :before-close="handleCloseRiskControl"
      width="60%"
    >
      <el-form :model="controlForm" :rules="controlRules">

        <div class="risk_control_basic">
          <el-row>

            <!-- 风险点名称 -->
            <el-col :span="12">
              <el-form-item label="风险点名称" prop="controlName">
                <div class="disabled_basic_div">
                  <el-input
                    placeholder="请输入风险点名称"
                    v-model="controlForm.controlName"
                    :disabled="true"
                    size="small">
                  </el-input>
                </div>
              </el-form-item>
            </el-col>

            <!-- 风险等级 -->
            <el-col :span="12">
              <div :class="{'control_basic_level_a' : controlForm.riskLevel === 'A', 'control_basic_level_b' : controlForm.riskLevel === 'B', 'control_basic_level_c' : controlForm.riskLevel === 'C', 'control_basic_level_d' : controlForm.riskLevel === 'D' }">
                <el-form-item label="风险等级" prop="riskLevel">
                  <div class="disabled_basic_div" v-if="selectedRisk.fxdj !== '' && selectedRisk.fxdj !== undefined">
                    <el-input
                      :disabled="true"
                      v-model="controlForm.riskLevel"
                      size="small">
                    </el-input>
                  </div>
                  <el-select 
                    v-else
                    v-model="controlForm.riskLevel" 
                    placeholder="请选择风险等级"
                    size="small"
                  >
                    <el-option
                      v-for="item in riskLevels"
                      :key="item.dictKey"
                      :label="item.dictValue"
                      :value="item.dictKey">
                    </el-option>
                  </el-select>
                </el-form-item>
              </div>
            </el-col>

          </el-row>
        </div>

        <div class="risk_control_second">
          <el-row>

            <!-- 负责人 -->
            <el-col :span="12">
              <div class="response_user_div">
                <el-form-item label="负责人" prop="responseUser">
                  <el-select 
                    v-model="controlForm.responseUser" 
                    clearable 
                    placeholder="请选择负责人"
                    size="small"
                    @change="changeRiskControlUser"
                    :disabled="controlType === viewLabel"
                  >
                    <el-option
                      v-for="user in userList"
                      :key="user.id"
                      :label="user.realName"
                      :value="user.id">
                    </el-option>
                  </el-select>
                </el-form-item>
              </div>
            </el-col>

            <!-- 风险等级 -->
            <el-col :span="12">
              <div class="contact_div">
                <el-form-item label="联系方式" prop="contact">
                  <el-input
                    placeholder="请输入联系方式"
                    v-model="controlForm.contact"
                    :disabled="controlType === viewLabel"
                    size="small">
                  </el-input>
                </el-form-item>
              </div>
            </el-col>

          </el-row>
        </div>

        <!-- 管理层级—：公司 -->
        <div class="risk_control_level">
          <el-row>
            <el-col :span="24">
              <el-form-item label="管理层级">
                <el-checkbox 
                  v-model="controlForm.hasGlcjgs" 
                  :disabled="controlType === viewLabel">
                  公司
                </el-checkbox>
                <div class="choose_user_div">
                  <el-button 
                    type="info" 
                    plain 
                    size="mini"
                    :disabled="controlType === viewLabel || !controlForm.hasGlcjgs"
                    @click="handleChooseUser(gsLabel)">
                    选择人员
                  </el-button>

                  <el-tag
                    v-for="(tag, index) in glcjgsTags"
                    :key="index"
                    size="medium "
                    :closable="controlType === updateLabel"
                    :disable-transitions="false"
                    @close="closeGlcjgsTags(index)">
                    {{tag.realName}}
                  </el-tag>
                </div>
              </el-form-item>
            </el-col>
          </el-row>
        </div>

        <!-- 管理层级—：部门 -->
        <div class="risk_control_level other_control_div">
          <el-row>
            <el-col :span="24">
              <el-form-item label="">
                <el-checkbox 
                  v-model="controlForm.hasGlcjbm" 
                  :disabled="controlType === viewLabel">
                  部门
                </el-checkbox>
                <div class="choose_user_div">
                  <el-button 
                    type="info" 
                    plain 
                    size="mini"
                    :disabled="controlType === viewLabel || !controlForm.hasGlcjbm"
                    @click="handleChooseUser(bmLabel)">
                    选择人员
                  </el-button>

                  <el-tag
                    v-for="(tag, index) in glcjbmTags"
                    :key="index"
                    size="medium "
                    :closable="controlType === updateLabel"
                    :disable-transitions="false"
                    @close="closeGlcjbmTags(index)">
                    {{tag.realName}}
                  </el-tag>
                </div>
              </el-form-item>
            </el-col>
          </el-row>
        </div>

        <!-- 管理层级—：车间 -->
        <div class="risk_control_level other_control_div">
          <el-row>
            <el-col :span="24">
              <el-form-item label="">
                <el-checkbox 
                  v-model="controlForm.hasGlcjcj"
                  :disabled="controlType === viewLabel">
                  车间
                </el-checkbox>
                <div class="choose_user_div">
                  <el-button 
                    type="info" 
                    plain 
                    size="mini"
                    :disabled="controlType === viewLabel || !controlForm.hasGlcjcj"
                    @click="handleChooseUser(cjLabel)">
                    选择人员
                  </el-button>

                  <el-tag
                    v-for="(tag, index) in glcjcjTags"
                    :key="index"
                    size="medium "
                    :closable="controlType === updateLabel"
                    :disable-transitions="false"
                    @close="closeGlcjcjTags(index)">
                    {{tag.realName}}
                  </el-tag>
                </div>
              </el-form-item>
            </el-col>
          </el-row>
        </div>

        <!-- 管理层级—：班组 -->
        <div class="risk_control_level other_control_div">
          <el-row>
            <el-col :span="24">
              <el-form-item label="">
                <el-checkbox 
                  v-model="controlForm.hasGlcjbz"
                  :disabled="controlType === viewLabel">
                  班组
                </el-checkbox>
                <div class="choose_user_div">
                  <el-button 
                    type="info" 
                    plain 
                    size="mini"
                    :disabled="controlType === viewLabel || !controlForm.hasGlcjbz"
                    @click="handleChooseUser(bzLabel)">
                    选择人员
                  </el-button>

                  <el-tag
                    v-for="(tag, index) in glcjbzTags"
                    :key="index"
                    size="medium "
                    :closable="controlType === updateLabel"
                    :disable-transitions="false"
                    @close="closeGlcjbzTags(index)">
                    {{tag.realName}}
                  </el-tag>
                </div>
              </el-form-item>
            </el-col>
          </el-row>
        </div>

        <!-- 管控措施：标题 -->
        <div class="risk_control_measure">
          <el-row>
            <el-col :span="24">
              <el-form-item>
                <template slot="label">
                  <span class="important_icon">*</span>
                  <span>管控措施</span>
                </template>
                <el-button 
                  type="primary"
                  size="small"
                  :disabled="controlType === viewLabel"
                  @click="addControlMeasure()">
                  添 加
                </el-button>
                <el-button 
                  type="success"
                  size="small"
                  :disabled="controlType === viewLabel"
                  @click="handleSelectControlMeasure()">
                  选 择
                </el-button>
              </el-form-item>
            </el-col>
          </el-row>
        </div>

        <!-- 管控措施：列表 -->
        <div class="control_measure_list">
          <el-row>
            <el-col :span="24">
              <el-form-item label="">
                <avue-crud 
                  :option="measureOption"
                  :data="measureData"
                  ref="measureCrud"
                >

                  <!-- 自定义操作列：删除按钮 -->
                  <template slot="menu" slot-scope="scope">
                    <el-button 
                      type="danger"
                      icon="el-icon-delete" 
                      size="small" 
                      :disabled="controlType === viewLabel"
                      @click="handleDeleteMeasure(scope.row, scope.index)">
                      删 除
                    </el-button>
                  </template>

                  <!-- 管控类型表格自定义 -->
                  <template slot="gklx" slot-scope="scope">
                    <el-select 
                      placeholder="请选择管控类型"
                      v-model="scope.row['gklx']" 
                      clearable 
                      size="small"
                      :disabled="controlType === viewLabel"
                    >
                      <el-option
                        v-for="(item, index) in controlMeasures"
                        :key="index"
                        :label="item.dictValue"
                        :value="item.dictKey">
                      </el-option>
                    </el-select>
                  </template>

                  <!-- 管控措施表格自定义 -->
                  <template slot="gkcs" slot-scope="scope">
                    <el-input
                      placeholder="请输入管控措施"
                      v-model="scope.row['gkcs']"
                      clearable
                      :disabled="controlType === viewLabel"
                      size="small">
                    </el-input>
                  </template>

                </avue-crud>
              </el-form-item>
            </el-col>
          </el-row>
        </div>

        <!-- 选择：承诺卡 -->
        <div class="choose_file_div">
          <el-row>
            <el-col :span="24">
              <div class="cnk_div">
                <el-form-item label="承诺卡">
                  <el-button 
                    type="success"
                    size="small"
                    @click="handleChoosePromise"
                    :disabled="controlType === viewLabel" >
                    选择承诺卡
                  </el-button>
                  <el-tag
                    style="margin-left: 10px;" 
                    v-for="(tag, index) in promiseTags"
                    :key="index"
                    size="medium"
                    :closable="controlType === updateLabel"
                    :disable-transitions="false"
                    @close="closePromiseTags(index)"
                  >
                    <span v-if="controlType === updateLabel">{{tag.cnkbh}}</span>
                    <a v-else :href="downloadHead + tag.fj" style="color: #409EFF;">
                      <i class="el-icon-download" style="margin-right: 5px;"></i>下载{{tag.cnkbh}}
                    </a>
                  </el-tag>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
        </div>

        <!-- 选择：承诺卡 -->
        <div class="choose_file_div">
          <el-row>
            <el-col :span="24">
              <div class="yjczk_div">
                <el-form-item label="应急处置卡" prop="yjczk">
                  <el-button 
                    type="success"
                    size="small"
                    @click="handleChooseEmergency"
                    :disabled="controlType === viewLabel" >
                    选择处置卡
                  </el-button>
                  <el-tag
                    style="margin-left: 10px;" 
                    v-for="(tag, index) in emergencyTags"
                    :key="index"
                    size="medium"
                    :closable="controlType === updateLabel"
                    :disable-transitions="false"
                    @close="closeEmergencyTags(index)"
                  >
                    <span v-if="controlType === updateLabel">{{tag.czkbh}}</span>
                    <a v-else :href="downloadHead + tag.fj" style="color: #409EFF;">
                      <i class="el-icon-download" style="margin-right: 5px;"></i>下载{{tag.czkbh}}
                    </a>
                  </el-tag>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
        </div>

        <!-- 按钮 -->
        <div class="risk_control_footer">
          <el-button 
            type="primary"
            size="small"
            @click="saveRiskControl"
            v-if="controlType === updateLabel"
            :loading="loadSaveRiskControl">
            保 存
          </el-button>
          <el-button 
            size="small"
            v-if="controlType === updateLabel"
            @click="cancelSaveRiskControl">
            取 消
          </el-button>
          <el-button 
            type="primary"
            size="small"
            v-if="controlType === viewLabel"
            @click="confirmSaveRiskControl">
            确 认
          </el-button>
        </div>

      </el-form>
    </el-dialog>

    <!-- 弹窗：选择人员 -->
    <glcjuser 
      :chooseUserDialog="chooseUserDialog" 
      :chooseUserName="chooseUserName" 
      :selectUserTags="selectUserTags" 
      @chooseUser="chooseUser" 
      @cancelChooseUser="cancelChooseUser" 
      @handleCloseGlcjUser="handleCloseGlcjUser">
    </glcjuser>

    <!-- 弹窗：选择管控措施 -->
    <controlmeasuredialog 
      :chooseMeasureDialog="chooseMeasureDialog"
      :filterYHJB="filterYHJB"
      @chooseControlMeasure="chooseControlMeasure" 
      @cancelChooseControlMeasure="cancelChooseControlMeasure" 
      @handleCloseChooseMeasure="handleCloseChooseMeasure">
    </controlmeasuredialog>

    <!-- 弹窗：选择承诺卡 -->
    <promisecarddialog 
      :choosePromiseDialog="choosePromiseDialog" 
      :filterPromiseName="filterPromiseName" 
      :selectPromiseTags="selectPromiseTags" 
      @choosePromise="choosePromise" 
      @cancleChoosePromise="cancleChoosePromise" 
      @handleCloseChoosePromise="handleCloseChoosePromise">
    </promisecarddialog>

    <!-- 弹窗：选择应急处置卡 -->
    <emergencycarddialog 
      :chooseEmergencyDialog="chooseEmergencyDialog" 
      :filterEmergencyName="filterEmergencyName" 
      :selectEmergencyTags="selectEmergencyTags" 
      @chooseEmergency="chooseEmergency" 
      @cancleChooseEmergency="cancleChooseEmergency" 
      @handleCloseChooseEmergency="handleCloseChooseEmergency">
    </emergencycarddialog>
    
	</div>
</template>

<script>
import { getControlMeasureTypes, getUserList, getRiskControlDetail, removeRiskControlMeasure, addRiskControl, getRiskLevelList } from "@/api/saferisk/riskpoint";
import glcjuser from './glcjuser.vue';
import controlmeasuredialog from './controlmeasuredialog.vue'
import promisecarddialog from './promisecarddialog.vue'
import emergencycarddialog from './emergencycarddialog.vue'

export default {
  components: { 
    glcjuser,
    controlmeasuredialog,
    promisecarddialog,
    emergencycarddialog
  }, 
  props: {
    riskControlDialog: {default: false},
    selectRiskId: {default: ""},
    selectRiskControlId: {default: ""},
    controlType: {default: "UPDATE"},
    selectedRisk: {default: {}}
  },
  data() {
    return {
      controlForm: {
        controlName: "",
        riskLevel: "",
        responseUser: "",
        contact: "",
        hasGlcjgs: false,
        hasGlcjbm: false,
        hasGlcjcj: false,
        hasGlcjbz: false
      },
      controlRules: {
        controlName: [{ required: true, message: '请输入风险点名称', trigger: 'blur' }],
        riskLevel: [{ required: true, message: '请输入风险等级', trigger: 'blur' }],
        responseUser: [{ required: true, message: '请选择负责人', trigger: 'change' }],
        contact: [{ required: true, message: '请输入联系方式', trigger: 'blur' }]
      },
      loadSaveRiskControl: false,
      controlMeasures: [],
      userList: [],
      riskLevels: [],
      updateLabel: "UPDATE",
      viewLabel: "VIEW",
      glcjgsTags: [],
      glcjbmTags: [],
      glcjcjTags: [],
      glcjbzTags: [],
      measureData: [],
      measureOption: {
        calcHeight: 30,
        tip: false,
        index: true,
        selection: false,
        addBtn: false,
        refreshBtn: false,
        columnBtn: false,
        indexWidth: 30,
        editBtn: false,
        delBtn: false,
        menuWidth: 100,
        column: [
          {
            label: "类型",
            prop: "gklx",
            align: "center",
            slot: true,
            width: 200
          },
          {
            label: "管控措施",
            prop: "gkcs",
            align: "center",
            slot: true
          }
        ]
      },
      userType: "",
      gsLabel: "gs",
      bmLabel: "bm",
      cjLabel: "cj",
      bzLabel: "bz",
      downloadHead: "/api/fileManager/download/",
      // 弹窗：选择人员
      chooseUserDialog: false,
      chooseUserName: "",
      selectUserTags: [],
      // 弹窗：选择管控措施
      chooseMeasureDialog: false,
      filterYHJB: "",
      // 弹窗：选择承诺卡
      choosePromiseDialog: false,
      filterPromiseName: "",
      selectPromiseTags: [],
      promiseTags: [],
      // 弹窗：选择应急处置卡
      chooseEmergencyDialog: false,
      filterEmergencyName: "",
      selectEmergencyTags: [],
      emergencyTags: [],
      fxdjObj: {
        "1": "A",
        "2": "B",
        "3": "C",
        "4": "D"
      },
      fxdjObject: {
        "A": "1",
        "B": "2",
        "C": "3",
        "D": "4"
      }
    }
  },
  watch: {

    // 风险点管控显隐
    riskControlDialog() {
      if(this.riskControlDialog === true) {
        this.initData();
      }
    }

  },
  mounted() {
    this.getMeasureTypes();
    this.getUsers();
    this.getRiskLevels();
  },
  methods: {

    /**
     * 风险点管控
    */

    // 获取管控措施类型
    getMeasureTypes() {
      getControlMeasureTypes().then(res => {
        this.controlMeasures = res.data.data;
      });
    },

    // 获取人员列表
    getUsers() {
      getUserList().then(res => {
        this.userList = res.data.data;
      });
    },

    // 获取风险等级列表
    getRiskLevels() {
      getRiskLevelList().then(res => {
        this.riskLevels = res.data.data;
      });
    },

    // 初始化风险点管控弹窗
    initData() {
      if(this.controlType === this.updateLabel) {
        if(this.selectRiskControlId === "" || this.selectRiskControlId === undefined) {
          this.controlForm = {
            controlName: this.selectedRisk.fxdmc,
            riskLevel: this.selectedRisk.fxdj === "" || this.selectedRisk.fxdj === undefined ? "" : this.fxdjObj[this.selectedRisk.fxdj],
            responseUser: "",
            contact: "",
            hasGlcjgs: false,
            hasGlcjbm: false,
            hasGlcjcj: false,
            hasGlcjbz: false
          };
          this.glcjgsTags = [];
          this.glcjbmTags = [];
          this.glcjcjTags = [];
          this.glcjbzTags = [];
          this.measureData = [];
          this.promiseTags = [];
          this.emergencyTags = [];
        } else {
          this.getDetailedRiskControl(this.selectRiskControlId);
        }
      } else if(this.controlType === this.viewLabel) {
        this.getDetailedRiskControl(this.selectRiskControlId);
      }
    },

    // 获取风险点管控详情
    getDetailedRiskControl(riskControlId) {
      getRiskControlDetail(riskControlId).then(res => {
        var resData = res.data.data;
        this.controlForm = {
          controlName: resData.fxdmc,
          riskLevel: this.fxdjObj[resData.fxdj],
          responseUser:resData.zrr,
          contact: resData.zrrdh,
          hasGlcjgs: resData.glcjgs !== "" && resData.glcjgs !== undefined ? true : false,
          hasGlcjbm: resData.glcjbm !== "" && resData.glcjbm !== undefined ? true : false,
          hasGlcjcj: resData.glcjcj !== "" && resData.glcjcj !== undefined ? true : false,
          hasGlcjbz: resData.glcjbz !== "" && resData.glcjbz !== undefined ? true : false
        };
        this.glcjgsTags = resData.companyStaff && resData.companyStaff.length !== 0 ? resData.companyStaff : [];
        this.glcjbmTags = resData.departmentStaff && resData.departmentStaff.length !== 0 ? resData.departmentStaff : [];
        this.glcjcjTags = resData.workshopPersonnel && resData.workshopPersonnel.length !== 0 ? resData.workshopPersonnel : [];
        this.glcjbzTags = resData.crew && resData.crew.length !== 0 ? resData.crew : [];
        this.measureData = resData.riskControlMeasures;
        this.promiseTags = resData.promiseCards && resData.promiseCards.length !== 0 ? resData.promiseCards : [];
        this.emergencyTags = resData.emergencyCards && resData.emergencyCards.length !== 0 ? resData.emergencyCards : [];
      });
    },

    // 删除公司人员
    closeGlcjgsTags(index) {
      this.glcjgsTags.splice(index, 1);
    },

    // 删除部门人员
    closeGlcjbmTags(index) {
      this.glcjbmTags.splice(index, 1);
    },

    // 删除车间人员
    closeGlcjcjTags(index) {
      this.glcjcjTags.splice(index, 1);
    },

    // 删除班组人员
    closeGlcjbzTags(index) {
      this.glcjbzTags.splice(index, 1);
    },

    // 添加管控措施
    addControlMeasure() {
      this.measureData.push({
        gklx: "",
        gkcs: ""
      });
    },

    // 删除管控措施
    handleDeleteMeasure(row, index) {
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        if(row.id === "" || row.id === undefined) {
          this.measureData.splice(index, 1);
        } else {
          removeRiskControlMeasure(row.id).then(res => {
            if(res.data.success) {
              this.measureData.splice(index, 1);
              this.$message.success("操作成功!");
            }
          });
        }
      })
    },

    // 更换风险管控负责人
    changeRiskControlUser(value) {
      if(value === "" ||value === undefined) {
        this.controlForm.contact = "";
        return;
      }
      this.userList.forEach(item => {
        if(item.id === value) {
          this.controlForm.contact = item.phone;
        }
      });
    },

    // 保存风险管控
    saveRiskControl() {
      if(this.controlForm.controlName === "") {
        this.$message.warning("请输入风险点名称");
        return;
      }
      if(this.controlForm.riskLevel === "") {
        this.$message.warning("请选择风险等级");
        return;
      }
      if(this.controlForm.responseUser === "") {
        this.$message.warning("请选择负责人");
        return;
      }
      if(this.controlForm.contact === "") {
        this.$message.warning("请输入联系方式");
        return;
      }
      if(this.measureData.length === 0) {
        this.$message.warning("请添加管控措施");
        return;
      }
      var isEmpty = false;
      this.measureData.forEach(item => {
        if(item.gklx === "" || item.gklx === undefined || item.gkcs === "" || item.gkcs === undefined) {
          isEmpty = true;
        }
      });
      if(isEmpty) {
        this.$message.warning("请填写正确的管控措施");
        return;
      }
      this.loadSaveRiskControl = true;
      var insertData = {
        riskManagementId: this.selectRiskId,
        fxdmc: this.controlForm.controlName,
        fxdj: this.fxdjObject[this.controlForm.riskLevel],
        zrr: this.controlForm.responseUser,
        zrrdh: this.controlForm.contact,
        glcjgs: this.glcjgsTags.length !== 0 ? this.formatGLCJ(this.glcjgsTags) : "",
        glcjbm: this.glcjbmTags.length !== 0 ? this.formatGLCJ(this.glcjbmTags) : "",
        glcjcj: this.glcjcjTags.length !== 0 ? this.formatGLCJ(this.glcjcjTags) : "",
        glcjbz: this.glcjbzTags.length !== 0 ? this.formatGLCJ(this.glcjbzTags) : "",
        riskControlMeasures: [],
        cnk: this.promiseTags.length !== 0 ? this.formatCNK(this.promiseTags) : "",
        yjczk: this.emergencyTags.length !== 0 ? this.formatYJCZK(this.emergencyTags) : ""
      };
      if(this.selectRiskControlId !== "" && this.selectRiskControlId !== undefined) {
        insertData["id"] = this.selectRiskControlId;
      }
      this.measureData.forEach(item => {
        var measure = {
          gkcs: item.gkcs,
          gklx: item.gklx
        };
        if(item.id !== "" && item.id !== undefined) {
          measure["id"] = item.id;
        }
        if(item.riskControlId !== "" && item.riskControlId !== undefined) {
          measure["riskControlId"] = item.riskControlId;
        }
        insertData.riskControlMeasures.push(measure);
      });
      addRiskControl(insertData).then(res => {
        if(res.data.success) {
          this.loadSaveRiskControl = false;
          this.$emit('saveRiskControl');
        }
      });
    },

    // 格式化管理层级数据(,分隔的id)
    formatGLCJ(glcjArr) {
      let userIds = [];
      glcjArr.forEach(item => {
        userIds.push(item.id);
      });
      return userIds.join(",");
    },

    // 格式化承诺卡数据（,分割开的id）
    formatCNK(cnkArr) {
      let promiseIds = [];
      cnkArr.forEach(item => {
        promiseIds.push(item.id);
      });
      return promiseIds.join(",");
    },

    // 格式化应急处置卡数据（,分割开的id）
    formatYJCZK(czkArr) {
      let emergencyIds = [];
      czkArr.forEach(item => {
        emergencyIds.push(item.id);
      });
      return emergencyIds.join(",");
    },

    // 取消保存风险管控
    cancelSaveRiskControl() {
      this.$emit('cancelSaveRiskControl');
    },

    // 确认风险管控
    confirmSaveRiskControl() {
      this.$emit('confirmSaveRiskControl');
    },

    // 关闭弹窗
    handleCloseRiskControl(done) {
      done();
      this.$emit('handleCloseRiskControl');
    },

    /**
     * 弹窗：选择人员
    */

    // 打开选择人员弹窗
    handleChooseUser(type) {
      this.chooseUserDialog = true;
      this.chooseUserName = "";
      this.userType = type;
      this.selectUserTags = [];
      if(type === this.gsLabel) {
        this.selectUserTags = this.glcjgsTags;
      } else if(type === this.bmLabel) {
        this.selectUserTags = this.glcjbmTags;
      } else if(type === this.cjLabel) {
        this.selectUserTags = this.glcjcjTags;
      } else if(type === this.bzLabel) {
        this.selectUserTags = this.glcjbzTags;
      }
    },

    // 确认勾选人员
    chooseUser(list) {
      if(this.userType === this.gsLabel) {
        this.glcjgsTags = list;
      } else if(this.userType === this.bmLabel) {
        this.glcjbmTags = list;
      } else if(this.userType === this.cjLabel) {
        this.glcjcjTags = list;
      } else if(this.userType === this.bzLabel) {
        this.glcjbzTags = list;
      }
      this.chooseUserDialog = false;
      this.chooseUserName = "";
      this.selectUserTags = [];
    },

    // 关闭选择人员弹窗
    cancelChooseUser() {
      this.chooseUserDialog = false;
      this.chooseUserName = "";
      this.selectUserTags = [];
    },

    // 关闭选择人员弹窗
    handleCloseGlcjUser() {
      this.cancelChooseUser();
    },

    /**
     * 弹窗：选择管控措施
    */

    // 打开选择管控措施弹窗
    handleSelectControlMeasure() {
      this.chooseMeasureDialog = true;
      this.filterYHJB = "";
    },

    // 选择管控措施
    chooseControlMeasure(list) {
      list.forEach(item => {
        this.measureData.push({
          gklx: "",
          gkcs: item.gkcs
        });
      });
      this.chooseMeasureDialog = false;
      this.filterYHJB = "";
    },

    // 取消选择管控措施
    cancelChooseControlMeasure() {
      this.chooseMeasureDialog = false;
      this.filterYHJB = "";
    },

    // 关闭选择管控措施弹窗
    handleCloseChooseMeasure() {
      this.cancelChooseControlMeasure();
    },

    /**
     * 弹窗：选择承诺卡
    */

    // 关闭承诺卡标签
    closePromiseTags(index) {
      this.promiseTags.splice(index, 1);
    },

    // 打开选择承诺卡弹窗
    handleChoosePromise() {
      this.choosePromiseDialog = true;
      this.filterPromiseName = "";
      this.selectPromiseTags = this.promiseTags;
    },

    // 选择承诺卡
    choosePromise(list) {
      this.promiseTags = list;
      this.cancleChoosePromise();
    },
  
    // 取消选择承诺卡
    cancleChoosePromise() {
      this.choosePromiseDialog = false;
      this.filterPromiseName = "";
      this.selectPromiseTags = [];
    },

    // 关闭选择承诺卡弹窗
    handleCloseChoosePromise() {
      this.cancleChoosePromise()
    },

    /**
     * 弹窗：选择应急处置卡
    */

    // 关闭处置卡标签
    closeEmergencyTags(index) {
      this.emergencyTags.splice(index, 1);
    },

    // 打开选择处置卡弹窗
    handleChooseEmergency() {
      this.chooseEmergencyDialog = true;
      this.filterEmergencyName = "";
      this.selectEmergencyTags = this.emergencyTags;
    },

    // 选择处置卡
    chooseEmergency(list) {
      this.emergencyTags = list;
      this.cancleChooseEmergency();
    },
  
    // 取消选择处置卡
    cancleChooseEmergency() {
      this.chooseEmergencyDialog = false;
      this.filterEmergencyName = "";
      this.selectEmergencyTags = [];
    },

    // 关闭选择处置卡弹窗
    handleCloseChooseEmergency() {
      this.cancleChooseEmergency()
    },

  }
}
</script>